package cn.xiaov.dao;

import cn.xiaov.domain.Employee;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface EmployeeDao {

    /**
     * 查询所有
     * @return
     */
    @Select("select * from employee ")
    List<Employee> findAll();

    /**
     * 保存账户
     */
    @Insert("insert into employee(ename,gender,dpid) values(#{ename},#{gender},#{dpid})")
    void save(Employee employee);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from employee where id=#{id}")
    void delete(Integer id);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from employee where id =#{id}")
    Employee findById(Integer id);

    /**
     * 修改
     * @param employee
     */
    @Update("update employee set ename=#{ename},gender=#{gender},dpid=#{dpid} where id=#{id}")
    void update(Employee employee);
}
